﻿<?php
	$ym = $_GET['ym'];
	if($ym < 1)$ym = 1;
	$url = 'http://top.baidu.com/buzz?b=1';
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    $html = curl_exec($ch);
    curl_close($ch); 
    $bts = '';
    $zss = '';
    
	for($i = 0;$i < 40;$i ++)
	{
		$html = strstr($html, '<a class="list-title"');
		$html = strstr($html, '">');
		$a = strpos($html,'/a') - 1;
		$wenben = mb_substr($html , 0 , $a);
		
		$wenben = str_replace('">','',$wenben);

		$wenben = iconv("gb2312","utf-8//IGNORE",$wenben);
		$bts .= $wenben.'_';


		$html = strstr($html, '<td class="last">');
		$html = strstr($html, 'icon-');
		$html = strstr($html, '>');
		$a = strpos($html,'/span>') - 2;
		$wenben = mb_substr($html , 1 , $a);
		
		$wenben = str_replace('ise">','',$wenben);

		$wenben = iconv("gb2312","utf-8//IGNORE",$wenben);
		$zss .= $wenben.'_';

	}
    
	$arr = explode('_',$bts);
	$arrzs = explode('_',$zss);
	$html = file_get_contents('bangdan.htm');
	for($i = 0;$i < count($arr) && $i < 10;$i ++)
	{
		$jkm = $i;
		$url = 'tz.php?word='.$arr[$i].'&jkm='.$jkm;
		$html = str_replace('_anters_'.$i.'_zs',$arrzs[$i],$html);
		$html = str_replace('_anters_'.$i.'_lj',$url,$html);
		$html = str_replace('_anters_'.$i,$arr[$i],$html);
	}
    $html = str_replace('zlsbtsfzddf',$bts,$html);
    $html = str_replace('zlszssfzddf',$zss,$html);
	echo $html;
?>